﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace GBPVRLibrary.MetadataLibrary
{
    /// <summary>
    /// The base class that describes the most common metadata
    /// </summary>
    public abstract class Metadata:IDisposable
    {
        [MetadataAttribute]
        public string Title { get; set; }

        [MetadataAttribute]
        public string Subtitle { get; set; }

        [MetadataAttribute]
        public DateTime? Date { get; set; }

        [MetadataAttribute]
        public string Description { get; set; }

        [MetadataAttribute]
        public double Rating { get; set; }

        [MetadataAttribute]
        public TimeSpan? Duration { get; set; }

        [MetadataAttribute]
        public List<Image> MetadataArt { get; set; }

        [MetadataAttribute]
        public Image Thumbnail { get; set; }

        public int PlayCount { get; set; }

        #region IDisposable Members

        public void Dispose()
        {
            foreach (System.Reflection.PropertyInfo info in this.GetType().GetProperties())
            {
                if (info.PropertyType == typeof(Image) && (from att in info.GetCustomAttributes(false) select att.GetType()).Contains(typeof(MetadataAttribute)))
                {
                    Image value = info.GetValue(this, null) as Image;
                    if (value != null)
                        value.Dispose();
                }
            }
        }

        #endregion
    }

    public class MetadataAttribute : Attribute
    {

    }

    public interface IBannerMetadata
    {
        Image Banner { get; set; }
    }
}
